<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>打字机</title>
	</head>
	<body>
		<div id="context">
			
		</div>
	</body>
	<script type="text/javascript">
		window.onload = function(){
			var msg = "人的一生有两次最大的幸运，一次是遇见你，一次是走到底";
			var write = document.getElementById("context");
			var length = msg.length;
			var speed = 0;
			var timer = setInterval(()=>{
				if(speed <= length){
					write.innerHTML = msg.substring(0,speed) + '_';
					speed++;
				}else{
					clearInterval(timer);
				}
			},70);
		}
	</script>
</html>
